<?php
// +----------------------------------------------------------------------
// | ZGUAN [ 致力于帮助更多的中小企业实现低成本数字化转型 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.zguan.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ZGUAN 并不是自由软件，未经许可不能去掉ZGUAN 相关版权
// +----------------------------------------------------------------------
// | Author: ZGUAN Team <admin@zguan.cn>  0769-82282996  15899929162
// +----------------------------------------------------------------------
namespace app\validate\housing;

use think\Validate;

class HousingResourceValidate extends Validate
{
    protected $rule = [
        'housing_title|标题' => 'require',
        'property_id|物业' => 'number',
        'source_id|空置房间' => 'number',
        'rent_price|租金' => 'require|float',
        'rent_type|租金计算方式' => 'require|in:1,2',
        'room_size|房源面积' => 'require|float',
        'floor_name|楼层' => 'number',
        'floor_total|总层高' => 'number',
        'pay_num|支付方式' => 'require|number',
        'bet_num|押金方式' => 'require|number',
        'start_rent|起租期' => 'require|number',
        'cate_id|分类' => 'require|number',
        'free_rent|免租期' => 'require|number',
        'is_reg|营业执照' => 'require|in:1,2',
        'address|房源所在区域' => 'require',
    ];

    public function sceneAdd()
    {
        return $this->remove('id', 'require');
    }

    public function sceneEdit()
    {
        return $this->remove('id', 'require');
    }

    public function sceneDel()
    {
        return $this->only(['id'])->append('id', 'require|number');
    }

    /**
     * 预约看房
     * @return void
     *
     * @author Amos
     * 2024-06-12 16:19
     */
    public function sceneMakeAdd()
    {
        $this->only(['hope_date', 'hope_time'])
            ->remove('hope_date|预约日期', 'require')
            ->append('hope_time|预约时间', 'require');
    }
}